package com.example.piece.ui.activity

import android.os.Bundle
import android.view.View
import androidx.annotation.DrawableRes
import com.therouter.router.Autowired
import com.therouter.router.Route
import com.gyf.immersionbar.ktx.statusBarHeight
import com.example.base.ui.activity.BaseActivity
import com.example.piece.R
import com.example.piece.constant.Key
import com.example.piece.constant.RoutePath
import com.example.piece.databinding.ActivityPictureBinding
import com.example.piece.entity.Picture
import com.example.piece.ui.adapter.PicturePagerAdapter

@Route(path = RoutePath.MAIN_PICTURE)
class PictureActivity : BaseActivity<ActivityPictureBinding>() {

    @JvmField
    @Autowired(name = Key.DataKey.PICTURES)
    var pictures: List<Picture> = mutableListOf()

    @JvmField
    @Autowired(name = Key.DataKey.SELECTED_INDEX)
    var selectedIndex: Int = 0

    /**  左边第一个图标的资源 id  **/
    @DrawableRes
    val leftIcon1Res: Int = R.drawable.ic_back

    override val isTransparentStatusBar: Boolean = true

    override fun getContentRes(): Int = R.layout.activity_picture

    override fun initData(savedInstanceState: Bundle?) {
        mBinding.adapter = PicturePagerAdapter(supportFragmentManager, pictures)
        mBinding.leftIcon1Res = leftIcon1Res
        mBinding.statusBarHeight = statusBarHeight

    }

    override fun onResume() {
        super.onResume()
        mBinding.selectedIndex = selectedIndex
    }

    /**  左边第一个图标的点击事件  **/
     fun onClickLeftIcon1(view: View) {
        finish();
    }

}
